<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"    
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:s="http://jboss.com/products/seam/taglib">

  <ui:composition template="../WEB-INF/layout/template.xhtml">
   
    <ui:define name="left_content">
        <s:link action="#{roleAction.createRole}" 
          rendered="#{s:hasPermission('seam.account', 'create', null)}"
          value="#{messages['jsf.CreateRole']}"
        />
    </ui:define>
   
    <ui:define name="center_content">
        
      <script type="text/javascript">
        function confirmDelete()
        {
          return confirm("#{messages['jsf.AreYouSureYouWishToDeleteThisRoleThisActionCannotBeUndone']}");
        }
      </script>
      <rich:panel>
        <f:facet name="header">#{messages['jsf.RoleManager']}</f:facet>

        <h:form>
            <s:token allowMultiplePosts="true" />
	        <h:dataTable 
	            id="threads"
	            value="#{roles}" 
	            var="role"
	            cellspacing="0"
	            headerClass="columnHeader"
	            rowClasses="odd,even"
	            columnClasses=",,enabled,action"
	            styleClass="fullwidth">
	
	          <h:column width="auto">
	            <f:facet name="header">#{messages['jsf.Role']}</f:facet>
	            #{role}
	          </h:column>
	          <h:column width="auto">
	            <f:facet name="header">#{messages['jsf.MemberOf']}</f:facet>
	            #{roleSearch.getRoleGroups(role)}
	          </h:column>
	          <h:column width="auto">
	            <f:facet name="header">#{messages['jsf.Actions']}</f:facet>          
	            <s:fragment rendered="#{s:hasPermission('seam.role', 'update')}">
	              <h:commandLink value="#{messages['jsf.Edit']}" action="#{roleAction.editRole(roleSearch.selectedRole)}"/><span> | </span>
	            </s:fragment>
	            <h:commandLink value="#{messages['jsf.Delete']}" action="#{identityManager.deleteRole(roleSearch.selectedRole)}"
	                    rendered="#{s:hasPermission('seam.role', 'delete')}"
	                    onclick="return confirmDelete()"/>
	          </h:column>
	  	    </h:dataTable>
        </h:form>              
      </rich:panel>
    </ui:define>
    
  </ui:composition>
</html>
